﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using Copad.BusinessCard.Model;
using Copad.BusinessCard.BLL;

public partial class BackgroundManage_Left2 : BusinessCardPageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        UserInfo user = Manager.CurrentUser;
        List<SubModels> list = new List<SubModels>();

        if (user != null)
        {
            if (user.Groups.Find(x => x.Name == "系统管理员") != null)
            {
                list.Add(SubModels.AddCard);
                list.Add(SubModels.AddCategory);
                list.Add(SubModels.AddGroup);
                list.Add(SubModels.AddUser);
                list.Add(SubModels.Card);
                list.Add(SubModels.Category);
                list.Add(SubModels.Group);
                list.Add(SubModels.ParameterConfig);
                list.Add(SubModels.SetupPopedom);
                list.Add(SubModels.UPdatePassWord);
                list.Add(SubModels.Users);

            }
            else if (user.Groups.Find(x => x.Name == "部门经理") != null)
            {
                list.Add(SubModels.AddCard);
                list.Add(SubModels.AddCategory);
                list.Add(SubModels.AddGroup);
                list.Add(SubModels.AddUser);
                list.Add(SubModels.Card);
                list.Add(SubModels.Category);
                list.Add(SubModels.Group);
                list.Add(SubModels.SetupPopedom);
                list.Add(SubModels.UPdatePassWord);
                list.Add(SubModels.Users);
            }
            else if (user.Groups.Find(x => x.Name == "普通员工") != null)
            {
                list.Add(SubModels.AddCard);
                list.Add(SubModels.AddCategory);
                list.Add(SubModels.AddGroup);
                list.Add(SubModels.Card);
                list.Add(SubModels.Category);
                list.Add(SubModels.Group);
                list.Add(SubModels.UPdatePassWord);
            }
            else
            {
                list.Add(SubModels.Card);
            }
            this.labFunctions.Text = this.viewHtml(list); ;
        }
    }


    private string viewHtml(List<SubModels> list)
    {
        string str = null;
        List<Models> modelsList = ModelsBLL.GetShortCutModel(list);
        string text = "";
        for (int i = 0; i < modelsList.Count; i++)
        {
            if (modelsList[i].ModelName.Length > 8)
            {
                text = modelsList[i].ModelName.Substring(0, 8) + "(" + modelsList[i].TagData + ")";
            }
            else
            {
                text = modelsList[i].ModelName + "(" + modelsList[i].TagData + ")";
            }

            if (i == 0)
            {
                str += "<a href='" + modelsList[i].PageDirection + "' target=\"frmright\" id=\"Menu_On\">" + modelsList[i].ModelName + "</a>";
            }
            else
            {
                str += "<a href='" + modelsList[i].PageDirection + "' target=\"frmright\" onClick=\"ChgStyle(this);\">" + modelsList[i].ModelName + "</a>";
            }
        }
        return str;
    }
}
